package com.alterzhang.alterzhang.controller;

import com.alterzhang.alterzhang.config.redis.RedisUtil;
import com.alterzhang.alterzhang.entity.test.User;
import com.alterzhang.alterzhang.service.UserService;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
@Log
public class Test {

    @Autowired
    private UserService userService;

    @Autowired
    private RedisUtil redisUtil;

    @RequestMapping("/test")
    @ResponseBody
    public String test() {
        Integer a = 0;
        String end = "end";
        return "hello,zhangshuhan";
    }


    @RequestMapping("/success")
    public String success(Map<String,Object> map){
        map.put("hello","hello");
        return "success";
    }


    @RequestMapping("/findUserByUserName")
    @ResponseBody
    public User findUserByUserName(String userName) {


        redisUtil.set("zsh","zsh");
        log.info("========"+redisUtil.get("zsh"));
        return userService.findByUsername(userName);
    }
}
